#include "HelloWorldScene.h"
#include "utility.h"
//#include "pthread.h"
#include <boost/bind.hpp>
using namespace cocos2d;

CCScene* HelloWorld::scene()
{
    CCScene * scene = NULL;
    do 
    {
        // 'scene' is an autorelease object
        scene = CCScene::create();
        CC_BREAK_IF(! scene);

        // 'layer' is an autorelease object
        HelloWorld *layer = HelloWorld::create();
        CC_BREAK_IF(! layer);
		//CCDirector::sharedDirector()->replaceScene(scene);
        // add layer as a child to scene
        scene->addChild(layer);
    } while (0);

    // return the scene
    return scene;
}

void HelloWorld::draw(void)
{
	CCLayer::draw();
	/*
    CCSize s = CCDirector::sharedDirector()->getWinSize();
	
	CCPoint vs[] = { CCPointMake(0,0), CCPointMake(s.width,0), CCPointMake(s.width,s.height), CCPointMake(0,s.height)};
	ccColor4F col = {1.0,1.0,1.0,0.5};
	ccDrawSolidPoly( vs, 4, col);

	glLoadIdentity();
	glRotatef(m_roate,0.0,1.0,0.0);
	CCPoint vertices[] = { CCPointMake(0,0), CCPointMake(s.width/4,0), CCPointMake(s.width/4,s.height/4), CCPointMake(0,s.height/4)};
	ccColor4F col1 = {1.0,0.0,0.0,0.5};
	ccDrawSolidPoly( vertices, 4, col1);

	*/
}

void OnLoadRes(CCTexture2D *pText)
{
	CCTexture2D *p = pText;
}
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
	return true;
}

void HelloWorld::menuCloseCallback(CCObject* pSender)
{
    // "close" menu item clicked
    //CCDirector::sharedDirector()->end();
	m_roate += 20;
}

void HelloWorld::UpdatePlayer(float dt)
{
	/*CCSize size = CCDirector::sharedDirector()->getWinSize();
	for(; m_curInitNum < GetActionNum(); m_curInitNum++)
	{
		CCSprite *pPlayer = NULL;//GetAction(m_curInitNum);
		if(pPlayer != NULL)
		{
			int w = Random(32,size.width-32);
			int h = Random(65,size.height-65);
			this->addChild(pPlayer);
			pPlayer->setPosition(ccp(w,h));
		}
	}*/
	m_roate += 5;
}

